home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevpdfg.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.6 KB  |  226 lines

  1. /* Copyright (C) 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevpdfg.h,v 1.9 2000/09/19 19:00:17 lpd Exp $ */
  20. /* Internal graphics interfaces for PDF-writing driver. */
  21.  
  22. #ifndef gdevpdfg_INCLUDED
  23. #  define gdevpdfg_INCLUDED
  24.  
  25. #include "gscspace.h"        /* for gs_separation_name */
  26.  
  27. /* ---------------- Exported by gdevpdfc.c ---------------- */
  28.  
  29. /* Define standard and short color space names. */
  30. /*
  31.  * Based on Adobe's published PDF documentation, it appears that the
  32.  * abbreviations for the calibrated color spaces were introduced in
  33.  * PDF 1.1 (added to Table 7.3) and removed in PDF 1.2 (Table 8.1)!
  34.  */
  35. typedef struct pdf_color_space_names_s {
  36.     const char *DeviceCMYK;
  37.     const char *DeviceGray;
  38.     const char *DeviceRGB;
  39.     const char *Indexed;
  40. } pdf_color_space_names_t;
  41. #define PDF_COLOR_SPACE_NAMES\
  42.   "/DeviceCMYK", "/DeviceGray", "/DeviceRGB", "/Indexed"
  43. #define PDF_COLOR_SPACE_NAMES_SHORT\
  44.   "/CMYK", "/G", "/RGB", "/I"
  45. extern const pdf_color_space_names_t
  46.     pdf_color_space_names,
  47.     pdf_color_space_names_short;
  48.  
  49. /* Define an abstract color space type. */
  50. #ifndef gs_color_space_DEFINED
  51. #  define gs_color_space_DEFINED
  52. typedef struct gs_color_space_s gs_color_space;
  53. #endif
  54.  
  55. /*
  56.  * Create a local Device{Gray,RGB,CMYK} color space corresponding to the
  57.  * given number of components.
  58.  */
  59. int pdf_cspace_init_Device(P2(gs_color_space *pcs, int num_components));
  60.  
  61. /*
  62.  * Create a PDF color space corresponding to a PostScript color space.
  63.  * For parameterless color spaces, set *pvalue to a (literal) string with
  64.  * the color space name; for other color spaces, create a cos_array_t if
  65.  * necessary and set *pvalue to refer to it.  In the latter case, if
  66.  * by_name is true, return a string /Rxxxx rather than a reference to
  67.  * the actual object.
  68.  */
  69. int pdf_color_space(P5(gx_device_pdf *pdev, cos_value_t *pvalue,
  70.                const gs_color_space *pcs,
  71.                const pdf_color_space_names_t *pcsn,
  72.                bool by_name));
  73.  
  74. /* Create colored and uncolored Pattern color spaces. */
  75. int pdf_cs_Pattern_colored(P2(gx_device_pdf *pdev, cos_value_t *pvalue));
  76. int pdf_cs_Pattern_uncolored(P2(gx_device_pdf *pdev, cos_value_t *pvalue));
  77.  
  78. /* Set the ProcSets bits corresponding to an image color space. */
  79. void pdf_color_space_procsets(P2(gx_device_pdf *pdev,
  80.                  const gs_color_space *pcs));
  81.  
  82. /* ---------------- Exported by gdevpdfg.c ---------------- */
  83.  
  84. /* Reset the graphics state parameters to initial values. */
  85. void pdf_reset_graphics(P1(gx_device_pdf *pdev));
  86.  
  87. /* Set the fill or stroke color. */
  88. /* pdecolor is &pdev->fill_color or &pdev->stroke_color. */
  89. int pdf_set_pure_color(P4(gx_device_pdf *pdev, gx_color_index color,
  90.               gx_drawing_color *pdcolor,
  91.               const psdf_set_color_commands_t *ppscc));
  92. int pdf_set_drawing_color(P4(gx_device_pdf *pdev,
  93.                  const gx_drawing_color *pdc,
  94.                  gx_drawing_color *pdcolor,
  95.                  const psdf_set_color_commands_t *ppscc));
  96.  
  97. /*
  98.  * Bring the graphics state up to date for a drawing operation.
  99.  * (Text uses either fill or stroke.)
  100.  */
  101. int pdf_prepare_fill(P2(gx_device_pdf *pdev, const gs_imager_state *pis));
  102. int pdf_prepare_stroke(P2(gx_device_pdf *pdev, const gs_imager_state *pis));
  103. int pdf_prepare_image(P2(gx_device_pdf *pdev, const gs_imager_state *pis));
  104. int pdf_prepare_imagemask(P3(gx_device_pdf *pdev, const gs_imager_state *pis,
  105.                  const gx_drawing_color *pdcolor));
  106.  
  107. /* Get the (string) name of a separation, */
  108. /* returning a newly allocated string with a / prefixed. */
  109. /****** BOGUS for all but standard separations ******/
  110. int pdf_separation_name(P3(gx_device_pdf *pdev, cos_value_t *pvalue,
  111.                gs_separation_name sname));
  112.  
  113. /* ---------------- Exported by gdevpdfj.c ---------------- */
  114.  
  115. /* ------ Image stream dictionaries ------ */
  116.  
  117. /* Define the long and short versions of the keys in an image dictionary, */
  118. /* and other strings for images. */
  119. typedef struct pdf_image_names_s {
  120.     pdf_color_space_names_t color_spaces;
  121.     pdf_filter_names_t filter_names;
  122.     const char *BitsPerComponent;
  123.     const char *ColorSpace;
  124.     const char *Decode;
  125.     const char *Height;
  126.     const char *ImageMask;
  127.     const char *Interpolate;
  128.     const char *Width;
  129. } pdf_image_names_t;
  130. #define PDF_IMAGE_PARAM_NAMES\
  131.     "/BitsPerComponent", "/ColorSpace", "/Decode",\
  132.     "/Height", "/ImageMask", "/Interpolate", "/Width"
  133. #define PDF_IMAGE_PARAM_NAMES_SHORT\
  134.     "/BPC", "/CS", "/D", "/H", "/IM", "/I", "/W"
  135. extern const pdf_image_names_t pdf_image_names_full, pdf_image_names_short;
  136.  
  137. /* Store the values of image parameters other than filters. */
  138. /* pdev is used only for updating procsets. */
  139. /* pcsvalue is not used for masks. */
  140. int pdf_put_image_values(P5(cos_dict_t *pcd, gx_device_pdf *pdev,
  141.                 const gs_pixel_image_t *pic,
  142.                 const pdf_image_names_t *pin,
  143.                 const cos_value_t *pcsvalue));
  144.  
  145. /* Store filters for an image. */
  146. /* Currently this only saves parameters for CCITTFaxDecode. */
  147. int pdf_put_image_filters(P4(cos_dict_t *pcd, gx_device_pdf *pdev,
  148.                  const psdf_binary_writer * pbw,
  149.                  const pdf_image_names_t *pin));
  150.  
  151. /* ------ Image writing ------ */
  152.  
  153. /* Define the maximum size of an in-line image. */
  154. #define MAX_INLINE_IMAGE_BYTES 4000
  155.  
  156. /*
  157.  * Fill in the image parameters for a device space bitmap.
  158.  * PDF images are always specified top-to-bottom.
  159.  * data_h is the actual number of data rows, which may be less than h.
  160.  */
  161. void pdf_make_bitmap_matrix(P6(gs_matrix * pmat, int x, int y, int w, int h,
  162.                    int h_actual));
  163.  
  164. /* Put out the gsave and matrix for an image. */
  165. void pdf_put_image_matrix(P3(gx_device_pdf * pdev, const gs_matrix * pmat,
  166.                  floatp y_scale));
  167.  
  168. /* Put out a reference to an image resource. */
  169. int pdf_do_image(P4(gx_device_pdf * pdev, const pdf_resource_t * pres,
  170.             const gs_matrix * pimat, bool in_contents));
  171.  
  172. /* Define the structure for writing an image. */
  173. typedef struct pdf_image_writer_s {
  174.     psdf_binary_writer binary;
  175.     const pdf_image_names_t *pin;
  176.     pdf_resource_t *pres;    /* XObject resource iff not in-line */
  177.     int height;            /* initially specified image height */
  178.     cos_stream_t *data;
  179.     const char *end_string;    /* string to write after EI if in-line */
  180. } pdf_image_writer;
  181. extern_st(st_pdf_image_writer);    /* public for gdevpdfi.c */
  182. #define public_st_pdf_image_writer()\
  183.   gs_public_st_suffix_add2(st_pdf_image_writer, pdf_image_writer,\
  184.     "pdf_image_writer", pdf_image_writer_enum_ptrs,\
  185.     pdf_image_writer_reloc_ptrs, st_psdf_binary_writer, pres, data)
  186. #define pdf_image_writer_max_ptrs (psdf_binary_writer_max_ptrs + 2)
  187.  
  188. /*
  189.  * Begin writing an image, creating the resource if not in-line and
  190.  * pres == 0, and setting up the binary writer.
  191.  */
  192. int pdf_begin_write_image(P7(gx_device_pdf * pdev, pdf_image_writer * piw,
  193.                  gx_bitmap_id id, int w, int h,
  194.                  pdf_resource_t *pres, bool in_line));
  195.  
  196. /* Begin writing the image data, setting up the dictionary and filters. */
  197. int pdf_begin_image_data(P4(gx_device_pdf * pdev, pdf_image_writer * piw,
  198.                 const gs_pixel_image_t * pim,
  199.                 const cos_value_t *pcsvalue));
  200.  
  201. /* Copy the data for a mask or monobit bitmap. */
  202. int pdf_copy_mask_bits(P7(stream *s, const byte *base, int sourcex,
  203.               int raster, int w, int h, byte invert));
  204.  
  205. /* Copy the data for a colored image (device pixels). */
  206. int pdf_copy_color_bits(P7(stream *s, const byte *base, int sourcex,
  207.                int raster, int w, int h, int bytes_per_pixel));
  208.  
  209. /* Finish writing the binary image data. */
  210. int pdf_end_image_binary(P3(gx_device_pdf *pdev, pdf_image_writer *piw,
  211.                 int data_h));
  212.  
  213. /*
  214.  * Finish writing an image.  If in-line, write the BI/dict/ID/data/EI and
  215.  * return 1; if a resource, write the resource definition and return 0.
  216.  */
  217. int pdf_end_write_image(P2(gx_device_pdf * pdev, pdf_image_writer * piw));
  218.  
  219. /* ---------------- Exported by gdevpdfv.c ---------------- */
  220.  
  221. /* Write a color value. */
  222. int pdf_put_drawing_color(P3(gx_device_pdf *pdev, const gx_drawing_color *pdc,
  223.                  const psdf_set_color_commands_t *ppscc));
  224.  
  225. #endif /* gdevpdfg_INCLUDED */
  226.